<?php

namespace App\Repositories;

use App\Models\Orderproduct;

/**
 * @auther 商品规格属性
 */

class OrderproductRepository
{

    // 列表
    public function list($where = [])
    {
        return Orderproduct::where($where)
            ->get();
    }
    // 分页列表
    public function pageList($where = [])
    {
        !isset($where['page']) ? $page = 15 : $page = $where['page'];

        return $userList = Orderproduct::orderBy('created_at', 'desc')->where(function ($query) use ($where) {
                if (isset($where['search'])) {
                    // $query->where('name', 'like', '%' . $where['search'] . '%');
                }
        })->paginate($page);
    }

    // add
    public function create($param)
    {
        $sys = new Orderproduct();
        $sys->fill($param)->save();
        return $sys->id;
    }

    // update
    public function update($param)
    {
        $sys = Orderproduct::find($param['id']);
        return $sys->fill($param)->save();
    }

    // del
    public function delete($id)
    {
        return Orderproduct::where('id', $id)->delete();
    }

    // info
    public function info($param)
    {
        return Orderproduct::where($param)->first();
    }
}
